//
//  UIView+Addtion.m
//  CwhiskyProject
//
//  Created by mac on 2019/1/2.
//  Copyright © 2019 cwhisky. All rights reserved.
//

#import "UIView+Addtion.h"

@implementation UIView (Addtion)
- (CGFloat)x {
    return self.frame.origin.x;
}

- (void)setX:(CGFloat)x {
    CGRect rc = self.frame;
    rc.origin.x = x;
    self.frame = rc;
}

- (CGFloat)y {
    return self.frame.origin.y;
}

- (void)setY:(CGFloat)y {
    CGRect rc = self.frame;
    rc.origin.y = y;
    self.frame = rc;
}

- (CGFloat)w {
    return self.frame.size.width;
}

- (void)setW:(CGFloat)w {
    CGRect rc = self.frame;
    rc.size.width = w;
    self.frame = rc;
}

- (CGFloat)h {
    return self.frame.size.height;
}

- (void)setH:(CGFloat)h {
    CGRect rc = self.frame;
    rc.size.height = h;
    self.frame = rc;
}

- (CGFloat)width {
    return self.frame.size.width;
}

- (void)setWidth:(CGFloat)width {
    CGRect rc = self.frame;
    rc.size.width = width;
    self.frame = rc;
}

- (CGFloat)height {
    return self.frame.size.height;
}

- (void)setHeight:(CGFloat)height {
    CGRect rc = self.frame;
    rc.size.height = height;
    self.frame = rc;
}

- (CGPoint)origin {
    return self.frame.origin;
}

- (void)setOrigin:(CGPoint)origin {
    CGRect rc = self.frame;
    rc.origin = origin;
    self.frame = rc;
}

- (CGSize)size {
    return self.frame.size;
}

- (void)setSize:(CGSize)size {
    CGRect rc = self.frame;
    rc.size = size;
    self.frame = rc;
}

- (CGFloat)maxX {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setMaxX:(CGFloat)maxX {
    CGRect rc = self.frame;
    CGFloat d = maxX - self.x;
    if (d <= 0) {
        rc.size.width = 0;
    } else {
        rc.size.width = d;
    }
    self.frame = rc;
}

- (CGFloat)maxY {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setMaxY:(CGFloat)maxY {
    CGRect rc = self.frame;
    CGFloat d = maxY - self.y;
    if (d <= 0) {
        rc.size.height = 0;
    } else {
        rc.size.height = d;
    }
    self.frame = rc;
}
@end
